from typing import List


class Solution:
    def maxStrength(self, nums: List[int]) -> int:
        result = 1
        # 0数量
        c_0 = 0
        # 负数数量
        c_f = 0
        # 整数数量
        c_z = 0
        # 最大负数
        max_cf = 0
        for num in nums:
            if num == 0:
                c_0 += 1
            elif num > 0:
                c_z += 1
                result *= num
            else:
                c_f += 1
                if max_cf == 0:
                    max_cf = num
                elif num > max_cf:
                    result *= max_cf
                    max_cf = num
                else:
                    result *= num

        # 只有一个负数
        # print(c_z, c_f, c_z, max_cf)
        if c_0 == 0 and c_f == 1 and c_z == 0:
            return max_cf
        # 只有0或者0和一个负数
        if c_z == 0 and c_f <= 1:
            return 0

        # 没有负数或者只有一个负数
        if c_f <= 1:
            return result
        # print(result)
        # print(max_cf)
        # print(c_f)
        if c_f % 2 == 0:
            result = result * max_cf
        return result


if __name__ == '__main__':
    nums = [-2, 0, -1]
    s = Solution()

    print(s.maxStrength(nums))
